<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>登录</title>
<%@ include file="/view/common/import.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/common/css/bootstrap.min.css?v=3.3.5" >
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/common/css/font-awesome.min.css?v=4.4.0" >
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/common/css/animate.min.css" >
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/common/css/style.min.css?v=4.0.0" >
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/common/css/drag.css" >
<script src="<%=request.getContextPath()%>/static/common/js/drag.js"></script>
</head>

<body class="gray-bg" style="font-family:Microsoft YaHei;">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>
                
                <h1 class="logo-name"><img src="<%=request.getContextPath() %>/static/common/img/login.png"></h1>

            </div>
            <h3>欢迎使用上善云图系统在线考试系统</h3>

            <form class="m-t" id="form" action="<%=request.getContextPath() %>/SystemServlet?command=login" method="POST">
                <div class="form-group">
                    <input type="text" class="form-control" id="code" name="code" placeholder="用户名"  style="border-radius: 5px;" value="1">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" id="password" name="password" placeholder="密码"  style="border-radius: 5px;" value="1">
                </div>
                
                <div id="drag"></div>
                
                <button type="submit" id="submit" class="btn btn-primary block full-width m-b" style="margin-top:15px;
                ">登 录</button>
               
                <p class="text-muted text-center"> <a href="login.html#"><small>忘记密码了？</small></a> | <a href="#">注册一个新账号</a>
                </p>

            </form>
        </div>
    </div>
    <script>
    	var result = $('#drag').drag();
	    $("#form").submit(function(){ 
	    	var code = $('#code');
    		var password = $('#password');
    		if(code.val()=='' || password.val()==''){
	        	layer.msg('帐号或密码不能为空！', {
	       			  time: 0 //不自动关闭
	       			  ,btn: ['确认']
	       			  ,yes: function(index){
	       			    layer.close(index);
	       			  }
	        	});
	          return false;  
	        } 
    		if(result != 1){
	        	layer.msg('请先完成滑动块验证！', {
	       			  time: 0 //不自动关闭
	       			  ,btn: ['确认']
	       			  ,yes: function(index){
	       			    layer.close(index);
	       			  }
	        	});
	          return false;  
	        } 
	    }); 
    </script>
    <script src="<%=request.getContextPath() %>/static/common/layer/layer.js"></script>
    <c:if test="${'fail'==flag}">
       	<script>
        	  window.onload = function () {
        		  layer.msg('帐号或密码错误，是否继续登录？', {
       			  time: 0 //不自动关闭
       			  ,btn: ['确认']
       			  ,yes: function(index){
       			    layer.close(index);
       			    location='<%=request.getContextPath()%>/login.jsp'
       			  }
       			});
             };
      	  </script>
    </c:if>
    <c:if test="${'failState'==flag}">
       	<script>
        	  window.onload = function () {
        		  layer.msg('状态为禁止登录，请与管理员联系！', {
       			  time: 0 //不自动关闭
       			  ,btn: ['确认']
       			  ,yes: function(index){
       			    layer.close(index);
       			    location='<%=request.getContextPath()%>/login.jsp'
       			  }
       			});
             };
      	  </script>
    </c:if>
</body>
</html>